package cn.edu.scau.dengzejun.comprehensive;

import javax.xml.ws.AsyncHandler;

public class Calculate {
	public String countTopNumber(String[] s) {
		int number = 0;
		for (int i = 0; i < s.length; ++i) {
			if (Integer.parseInt(s[i]) >= 90) {
				number++;
			}
		}
		return Integer.toString(number);
	}

	public String countTopMiddle(String[] s) {
		int number = 0;
		for (int i = 0; i < s.length; ++i) {
			if ((Integer.parseInt(s[i]) >= 80) && (Integer.parseInt(s[i]) < 90)) {
				number++;
			}
		}
		return Integer.toString(number);
	}

	public String countMiddle(String[] strings) {
		int number = 0;
		for (int i = 0; i < strings.length; ++i) {
			if ((Integer.parseInt(strings[i]) >= 70) && (Integer.parseInt(strings[i]) < 80)) {
				number++;
			}
		}
		return Integer.toString(number);
	}

	public String countUnderMiddle(String[] strings) {
		int number = 0;
		for (int i = 0; i < strings.length; ++i) {
			if ((Integer.parseInt(strings[i]) >= 60) && (Integer.parseInt(strings[i]) < 70)) {
				number++;
			}
		}
		return Integer.toString(number);
	}

	public String countUnder(String[] strings) {
		int number = 0;
		for (int i = 0; i < strings.length; ++i) {
			if ((Integer.parseInt(strings[i]) < 60) && (Integer.parseInt(strings[i]) >= 0)) {
				number++;
			}
		}
		return Integer.toString(number);
	}

	public String countPercentage(String string, int all) {
		double percentage = 0;
		int number = Integer.parseInt(string);
		percentage = (double) number / all * 100;
		String temp = String.format("%.2f", percentage);
		return temp;
	}

}
